<template>
    <div class="tabulation">
      <!-- 数据加载等待 -->
      <Loading v-if="loading"></Loading>
      <div v-for="item in nowplays" class="item" :key="item.filmId">
        <div class="left">
          <img :src="item.poster" />
        </div>
        <div class="middle">
          <div>{{item.name}}</div>
          <div>
            <span>观众评分</span>
            <span>7.6</span>
          </div>
          <div>
              主演：{{item.actors | actorsFilter}}
          </div>
          <div>美国，英国 | 150分钟</div>
        </div>
        <div class="right">
          <span :style="[{color,border:`1px solid ${color}`}]">{{ title }}</span>
        </div>
      </div>
    </div>
</template>

<script>

//  数据加载等待
import Loading from "./Loading";

export default {
  components: {
    Loading
  },
  props: {
    title: {
      //默认样式
      default: "购票",
    },
    color: {
      default: "#ff5f16",
    },
    nowplays:Array,

  },
  data() {
    return {
      loading: true,
    };
  },

  created() {
    if (this.nowplays.length > 0) {
      this.loading = false;
    }
  },

  filters:{
    actorsFilter(value){
      if(!value){
        return '无';
      }
      // 数组map方法
      // return value.map(item=>item.name).join(',');
      //数组循环方法
      let actor=''
      value.forEach(item=>{
        actor+=item.name+',';
      });
      return actor.slice(0,-1)

    }
  },

  mounted() {
//     urlFn(id) {
//       // 编程式导航
//       this.$router.push({ name: "detail", params: { id } });
//     },
  },
};
</script>

<style lang="scss" scoped>
.tabulation{
  margin-top: 5px;
}
.item {
  margin-top: 5px;
  display: flex;
  color: #797d82;
  font-size: 13px;
  .left {
    width: 30%;
    height: 100px;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .middle {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 55%;
    margin-left: 5px;
    div:nth-of-type(1) {
      color: #191a1b;
      font-size: 16px;
    }
    div:nth-of-type(3) {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }
  .right {
    width: 15%;
    display: flex;
    align-items: center;
    span {
      border: 1px solid #ff5f16;
      background: white;
      color: #ff5f16;
      border-radius: 2px;
      height: 25px;
      line-height: 25px;
      font-size: 13px;
      width: 50px;
      text-align: center;
    }
  }
}
</style>